// ****************************************************************************
// *     Filename:  MyHit.cc
// *  Description:  
// *      License:  Geant4 Software License 
// *                http://geant4.cern.ch/license/LICENSE.html
// *       Author:  Tran Hoai Nam (nam), nam@kuno-g.phys.sci.osaka-u.ac.jp
// * Organization:  Osaka University
// *      Created:  2012-09-14 13:00:19
// ****************************************************************************

#include "MyHit.hh"

G4Allocator<MyHit> MyHitAllocator;

MyHit::MyHit() 
{
	fedep = 0.;
	fDetName = "";
	fCopyNo = 10000;

	fPriStopFlag = fNewFlag = false;
	fDirection = 0;
}

MyHit::~MyHit()
{;}

bool MyHit::Before(const MyHit& h1, const MyHit& h2) 
{
	return (h1.fTime < h2.fTime);
}

void MyHit::Print() 
{
	if(fHitType==CaloHit) 
	{
		printf("Det %d: Edep %.05f, time %.06f\n",fCopyNo,fedep,fTime);
	}
	else if(fHitType==TrackerHit)
	{
		if(fPriStopFlag)
		{
			G4cout<<"Primary stopped at: "<<fStopPoint/mm;
			G4cout<<", time: "<<fStopTime/ns<<"\n";
		}

		if(fDirection==1)
		{
			G4cout<<"Particle: "<<fName<<", trackID "<<fTrackID<<", entered";
			G4cout<<", at"<<fPos/mm;
			G4cout<<", KE: "<<fKE/MeV<<G4endl;
		}

		if(fDirection==-1)
		{
			G4cout<<"Particle: "<<fName<<", trackID "<<fTrackID<<", exited";
			G4cout<<", at"<<fPos/mm;
			G4cout<<", KE: "<<fKE/MeV<<G4endl;
		}

		if(fNewFlag)
		{
			G4cout<<"New particle: "<<fNewName<<", trackID "<<fNewTrackID;
			G4cout<<", at"<<fNewPoint/mm;
			G4cout<<", KE: "<<fNewKE/MeV<<G4endl;
		}
	}
}

void MyHit::Draw()
{;}
